package com.zunipe.chat;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import com.zunipe.chat.bean.Message;

import java.util.ArrayList;
import java.util.List;

public class MainViewModel extends ViewModel {
    public MutableLiveData<List<Message>> messageList = new MutableLiveData<>(new ArrayList<>());

    public void addMessage(Message message) {
        List<Message> listValue = messageList.getValue();
        if (listValue != null) {
            listValue.add(message);
            messageList.setValue(listValue);
        }
    }

    public MutableLiveData<List<Message>> getMessageList() {
        return this.messageList;
    }
}
